<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <label for="">全选<input class="checkall" type="checkbox"></label><br>
    <label for="">A<input class="checkone" type="checkbox"></label>
    <label for="">B<input class="checkone" type="checkbox"></label>
    <label for="">C<input class="checkone" type="checkbox"></label>
    <label for="">D<input class="checkone" type="checkbox"></label>

    <script>
        var checkList = Array.from(document.querySelectorAll('.checkone'))
        var checkall = document.querySelector('.checkall')


        checkall.onclick = function () {
            checkList.forEach(function (item) {
                item.checked=checkall.checked
            })
        }

        checkList.forEach(function (check) {
            check.onclick = function () {
                checkall.checked = checkList.every(function (item) {
                    return item.checked == true
                })
            }
        })

    </script>
</body>

</html>